package com.csist.service.po.basicInfoModule.impl;

import com.csist.mapper.po.basicInfoModule.SpecificationMajorInfoMapper;
import com.csist.pojo.po.basicInfoModule.SpecificationMajorInfo;
import com.csist.service.po.basicInfoModule.SpecificationMajorInfoService;
import com.csist.util.SqlSessionUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.Collections;
import java.util.List;

/**
 * @ClassName SpecificationMajorInfoServiceImpl
 * @Description 【自行描述】
 * @Author cn
 * @Date 2024/6/27 12:53
 * @Version 1.0
 */
public class SpecificationMajorInfoServiceImpl implements SpecificationMajorInfoService {

    private SqlSession sqlSession;
    private SpecificationMajorInfoMapper specificationMajorInfoMapper;

    public SpecificationMajorInfoServiceImpl() {
        sqlSession = SqlSessionUtil.openSession();
        specificationMajorInfoMapper = sqlSession.getMapper(SpecificationMajorInfoMapper.class);
    }

    @Override
    public List<SpecificationMajorInfo> findAll() {
        List<SpecificationMajorInfo> list = specificationMajorInfoMapper.findAll();
        if (list != null && list.size() > 0) {
            return list;
        }
        return null;
    }

    @Override
    public SpecificationMajorInfo getSpecificationMajorInfoById(int id) {
        SpecificationMajorInfo specificationMajorInfoById = specificationMajorInfoMapper.getSpecificationMajorInfoById(id);
        if (specificationMajorInfoById != null) {
            return specificationMajorInfoById;
        }
        return null;
    }

    @Override
    public List<SpecificationMajorInfo> findSpecificationMajorInfoFuzzy(SpecificationMajorInfo specificationMajorInfo) {
        List<SpecificationMajorInfo> list = specificationMajorInfoMapper.findSpecificationMajorInfoFuzzy(specificationMajorInfo);
        if (list != null && list.size() > 0) {
            return list;
        }
        return null;
    }

    @Override
    public List<SpecificationMajorInfo> findSpecificationMajorInfo(SpecificationMajorInfo specificationMajorInfo) {
        List<SpecificationMajorInfo> list = specificationMajorInfoMapper.findSpecificationMajorInfo(specificationMajorInfo);
        if (list != null && list.size() > 0) {
            return list;
        }
        return null;
    }

    @Override
    public int addSpecificationMajorInfo(SpecificationMajorInfo specificationMajorInfo) {
        int i = specificationMajorInfoMapper.addSpecificationMajorInfo(specificationMajorInfo);
        if (i > 0) {
            sqlSession.commit();
            return i;
        }
        return 0;
    }

    @Override
    public int updateSpecificationMajorInfo(SpecificationMajorInfo specificationMajorInfo) {
        int i = specificationMajorInfoMapper.updateSpecificationMajorInfo(specificationMajorInfo);
        if (i > 0) {
            sqlSession.commit();
            return i;
        }
        return 0;
    }


    @Override
    public int updateSpecificationMajorInfoByState(int smiId) {
        int i = specificationMajorInfoMapper.updateSpecificationMajorInfoByState(smiId);
        if (i > 0) {
            sqlSession.commit();
            return i;
        }
        return 0;
    }

    @Override
    public int deleteSpecificationMajorInfo(int smiId) {
        return 0;
    }
}
